package com.si.store.adapter;

import java.util.List;

import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ArrayAdapter;
import android.widget.TextView;

import com.si.store.R;
import com.si.store.model.GamesAndApps;

public class AdapterSearch extends ArrayAdapter<GamesAndApps> {
	private Context context;
	private LayoutInflater inflater;
	int LayoutId;
	private List<GamesAndApps> list_game;
	ViewHolder holder;
	private class ViewHolder {
		TextView tvSearch;
		public ViewHolder(View view) {
			tvSearch = (TextView) view.findViewById(R.id.tv_suggest);
		}
		
		public void setData(GamesAndApps app){
			tvSearch.setText(app.getDowlaod());
		}
	}
	public AdapterSearch(Context ctx, int resouce, List<GamesAndApps> objects) {
		super(ctx, resouce, objects);
		this.context = ctx;
		this.list_game = objects;
		this.LayoutId = resouce;
		this.inflater = (LayoutInflater)context.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
	}
	@Override
	public View getView(int position, View convertView, ViewGroup parent) {
		if (convertView == null) {
			convertView = inflater.inflate(R.layout.item_suggest, parent, false);
			holder = new ViewHolder(convertView);
			convertView.setTag(holder);
		} else {
			holder = (ViewHolder) convertView.getTag();
		}
		holder.setData(list_game.get(position));
		return convertView;
	}

	

}
